package com.cartoon.service.impl;

import com.cartoon.entity.Collect;
import com.cartoon.dao.CollectDao;
import com.cartoon.service.CollectService;
import com.cartoon.util.ResponseData;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;

/**
 * (Collect)表服务实现类
 *
 * @author makejava
 * @since 2021-12-10 11:28:08
 */
@Service("collectService")
public class CollectServiceImpl implements CollectService {
    @Resource
    private CollectDao collectDao;


    @Override
    public ResponseData getCollectCartoons(int userId) {
        try{
          return new ResponseData("0","请求成功",collectDao.getCollectCartoons(userId));
        }
        catch (Exception e){
            e.printStackTrace();
            return new ResponseData("9924","出错了");
        }
    }

    @Override
    public ResponseData insertCollectCartoons(Integer cartoonId, Integer userId) {
        try{
            collectDao.insertCollectCartoons(cartoonId,userId);
            System.out.println(cartoonId+"  "+userId);
            return new ResponseData("0","插入收藏数据成功！");
        }
        catch (Exception e){
            return new ResponseData("9924","出错了");
        }
    }

    @Override
    public ResponseData deleteCollectCartoon(Integer cartoonId, Integer userId) {
        try{
            collectDao.deleteCollectCartoon(cartoonId,userId);
            return new ResponseData("0","删除收藏数据成功");
        }
        catch (Exception e){
            return new ResponseData("9924","删除收藏数据出错了！");
        }
    }
}
